package timer;

/**
 * The Class Timer is responsible for the timing of the game.
 * It's purpose is that the game runs in same speed on different
 * tools.
 */
public class Timer {
	
	/** The paused status. */
	private static boolean paused = false;
	
	static {
		time = System.currentTimeMillis();
	}
	
	/**
	 * Gets the delta time, which is the timedifference between
	 * now and the last time this function was called.
	 *
	 * @return the delta time
	 */
	public static float getDeltaTime() {
		if(paused)
			return 0;
			
		long oldTime = time;
		time = System.currentTimeMillis();
		
		return (float)((time - oldTime)) / 1000.0f;
	}
	
	/** The last time. */
	private static long time;
	
	/**
	 * Pauses the timer.
	 */
	public static void pauseTimer() {
		paused = true;
	}
	
	/**
	 * Continues the paused timer.
	 */
	public static void continueTimer() {
		paused = false;
		time = System.currentTimeMillis();
	}
}
